# -*- coding:utf-8 -*-
import requests


class PushData:
    def push_data(self, location_dict, daily_dict):
        # 向微信推送天气消息
        self.url = 'https://www.pushplus.plus/send?'
        self.payload = {'template ': 'markdown', 'topic': '西安天气'}
        # 消息推送Key
        self.payload['token'] = '6f1167593fc8412997daa8843bb8e483'
        # 推送消息Title
        self.payload['title'] = '%s 天气预报' % location_dict['name']
        # 推送消息Description
        self.content = """
        <b># 今日天气</b>
        * 日间最高温度：%s℃，%s
        * 夜间最高温度：%s℃，%s
        * 相对湿度：%s %%  
        * 风向：%s
        * 风力：%s 级
        * 风速：%s KM/H
            
        <b># 明日天气</b>
        * 日间最高温度：%s℃，%s
        * 夜间最高温度：%s℃，%s
        * 相对湿度：%s %% 
        * 风向：%s
        * 风力：%s 级
        * 风速：%s KM/H
        """% (
        daily_dict[0]['high'], daily_dict[0]['text_day'], daily_dict[0]['low'], daily_dict[0]['text_night'],
        daily_dict[0]['humidity'], daily_dict[0]['wind_direction'], daily_dict[0]['wind_scale'],
        daily_dict[0]['wind_speed'], daily_dict[1]['high'], daily_dict[1]['text_day'], daily_dict[1]['low'],
        daily_dict[1]['text_night'], daily_dict[1]['humidity'], daily_dict[1]['wind_direction'],
        daily_dict[1]['wind_scale'], daily_dict[1]['wind_speed'])
        self.payload['content'] = self.content
        res = requests.get(self.url, params=self.payload)
        print(res.text)
